import request from './request'
/**
 * Y购----获取首页的列表数据
 * import { getProlist } from '@/api'
 * 数据接口参考
 * http://localhost:3000/apidoc/#api-pro-GetApiPro
 * @param {object} params 由limit和count组成的
 */

export function getProlist (params) {
  // limit和count的默认值--依据接口文档设置
  const data = params || {
    limit: 10,
    count: 0
  }
  // 第一种
  // return request.get('/pro')
  // 第二种
  return request({
    url: '/pro',
    method: 'get',
    params: data
  })
}
/**
 * Y购----获取首页轮播数据
 */
export function getBannerlist () {
  return request({
    url: '/banner',
    method: 'get'
  })
}
/**
 * Y购----请求详情页的数据
 * @param { object } params 
 */
export function getDetail (params) {
  return request({
    url: '/pro/detail',
    method: "get",
    params
  })
}
/**
 * Y购----注册
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function register (params) {
  return request({
    url: '/users/register',
    method: 'post',
    data: params
  })
}
/**
 * Y购----登录
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function login (params) {
  return request({
    url: '/users/login',
    method: 'post',
    data: params
  })
}
/**
 * Y购----加入购物车
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function addCart (params) {
  return request({
    url: '/cart/add',
    method: 'post',
    data: params
  })
}
/**
 * Y购----购物车数据
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function YCart (params) {
  return request({
    url: '/cart',
    method: 'get',
    params
  })
}
/**
 * Y购----购物车加数据
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function Yupdate (params) {
  return request({
    url: '/cart/update',
    method: 'get',
    params
  })
}
/**
 * Y购----购物车删除数据
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function YdeleteData (params) {
  return request({
    url: '/cart/delete',
    method: 'get',
    params
  })
}
/**
 * Y购----购物车提交订单
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function Yorder (params) {
  return request({
    url: '/order/add',
    method: 'post',
    data: params
  })
}
/**
 * Y购----获取订单数据
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function Ygetorder (params) {
  return request({
    url: '/order',
    method: 'get',
     params
  })
}
/**
 * Y购----获取分类
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function Ykind () {
  return request({
    url: '/category/getCategory',
    method: 'get'
  })
}
/**
 * Y购----获取分类下的产品
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function Ykindlist (params) {
  return request({
    url: '/category/getCategoryBrand',
    method: 'get',
    params
  })
}



export function getHotlist (params) {
  return request({
    url: '/playlist/hot',
    method: 'get',
    params
  })
}

/**
 * 获取推荐列表数据
 * import { getNewSong } from '@/api'
 * 数据接口参考： http://localhost:3000/
 */
export function getNewSong (params) {
  return request({
    url: '/personalized/newsong',
    method: 'get',
    params
  })
}

/**
 * 获取精品歌单
 * import { getHighquality } from '@/api'
 * 数据接口参考： http://localhost:3000/
 */
export function getHighquality (params) {
  return request({
    url: '/top/playlist/highquality',
    method: 'get',
    params
  })
}
/**
 * 获取音乐url
 * import { getHighquality } from '@/api'
 * 数据接口参考： http://localhost:3000/
 */
export function getSong (params) {
  return request({
    url: '/song/url',
    method: 'get',
    params
  })
}
/**
 * 获取音乐详情
 * import { getSongDetail } from '@/api'
 * 数据接口参考： http://localhost:3000/
 */
export function getSongDetail (params) {
  return request({
    url: '/song/detail',
    method: 'get',
    params
  })
}
/**
 * 获取歌词
 * import { getlyric } from '@/api'
 * @param {id} params 歌曲id
 */
export function getlyric (params) {
  return request({
    url: '/lyric',
    method: 'get',
    params
  })
}

/**
 * 登录
 * @param {Object} params { phone: '', password: ''}
 */
export function GetLogin (params) {
  return request({
    url: '/login/cellphone',
    method: 'post',
    data: params
  })
}

/**
 * 获取推荐最高列表数据
 * import { getToplist } from '@/api'
 */
export function getToplist (params) {
  // const data = params || { limit: 9, count: 0 }
  return request({
    url: '/top/playlist',
    method: 'get',
    params
  })
}
/**
 * 获取推荐最高列表数据
 * import { getToplist } from '@/api'
 */
export function getkindlist (params) {
  // const data = params || { limit: 9, count: 0 }
  return request({
    url: '/top/playlist/highquality',
    method: 'get',
    params
  })
}

/**
 * 获取推荐列表数据
 * import { getRecom } from '@/api'
 * 数据接口参考： http://localhost:3000/
 */
export function getRecom (params) {
  // const data = params || { limit: 6, count: 0 }
  return request({
    url: '/personalized',
    method: 'get',
    params
  })
}

/**
 * 获取音乐列表数据
 * import { getlist } from '@/api'
 * @params {object} params 歌曲id
 */
export function getlist (params) {
  return request({
    url: '/playlist/detail',
    method: 'get',
    params
  })
}

/**
 * 心动用户
 * import { getLike } from '@/api'
 * @params {object} params 歌曲id 歌单id
 */
export function getLike (params) {
  return request({
    url: '/playmode/intelligence/list',
    method: 'get',
    params
  })
}

/**
 * 修改用户信息
 * import { updateAvatar } from '@/api'
 * @params {object} params 歌曲id 歌单id
 */
export function updateAvatar (params) {
  return request({
    url: 'http://localhost:3000/api/users/updateAvatar',
    method: 'post',
    data: params
  })
}

/**
 * 发送验证码
 * import { getCaptcha } from '@/api'
 * @params {object} params 手机号phone
 */
export function getCaptcha (params) {
  return request({
    url: 'http://localhost:3000/api/users/sendCode',
    method: 'get',
    params
  })
}

/**
 * 注册
 * import { setRegistera } from '@/api'
 * @params {object} params 手机号phone password
 */
export function setRegister (params) {
  return request({
    url: 'http://localhost:3000/api/users/register',
    method: 'post',
    data: params
  })
}

/**
 * 网易注册
 * import { WyRegister } from '@/api'
 * @params {object} params 手机号phone password nickname captcha
 */
export function WyRegister (params) {
  return request({
    url: '/register/cellphone',
    method: 'post',
    data: params
  })
}

/**
 * 网易获取短信验证码
 * import { sentCaptcha } from '@/api'
 * @params {object} params 手机号phone
 */
export function sentCaptcha (params) {
  return request({
    url: '/captcha/sent',
    method: 'post',
    data: params
  })
}

/**
 * 网易验证短信验证码
 * import { sentexting } from '@/api'
 * @params {object} params 手机号phone captcha
 */
export function sentexting (params) {
  return request({
    url: '/captcha/verify',
    method: 'post',
    data: params
  })
}

/**
 * 判断手机号是否已注册
 * import { repeatPhone } from '@/api'
 * @params {object} params 手机号 phone
 */
export function repeatPhone (params) {
  return request({
    url: '/cellphone/existence/check',
    method: 'post',
    data: params
  })
}

/**
 * 获取登录状态
 * import { getStatus } from '@/api'
 * @params {object} params token
 */
export function getStatus (params) {
  return request({
    url: '/login/status',
    method: 'post',
    data: params,
    withCredentials: true,
    headers: {
      'x-requested-with': 'XMLHttpRequset'
    }
  })
}

/**
 * 获取用户详情
 * import { getuserinfo } from '@/api'
 * @params {object} params uid
 */
export function getuserinfo (params) {
  return request({
    url: '/user/detail',
    method: 'post',
    data: params
  })
}

/**
 * 获取用户歌单
 * import { getuserSongList } from '@/api'
 * @params {object} params uid
 */
export function getuserSongList (params) {
  return request({
    url: '/user/playlist',
    method: 'post',
    data: params,
    withCredentials: true,
    headers: {
      'x-requested-with': 'XMLHttpRequset'
    }
  })
}

/**
 * 获取用户播放记录
 * import { getuserPlaybackRecord } from '@/api'
 * @params {object} params uid
 */
export function getuserPlaybackRecord (params) {
  return request({
    url: '/user/record',
    method: 'post',
    data: params
  })
}

/**
 * 获取收藏的歌手
 * import { getcllectionSonger } from '@/api'
 */
export function getcllectionSonger (params) {
  return request({
    url: '/artist/sublist',
    method: 'get',
    params
  })
}

/**
 * 退出登录
 * import { signout } from '@/api'
 */
export function signout (params) {
  return request({
    url: '/logout',
    method: 'get',
    params
  })
}

/**
 * 更新用户信息
 * import { upUserInfo } from '@/api'
 */
export function upUserInfo (params) {
  return request({
    url: '/user/update',
    method: 'get',
    params
  })
}
